package com.copote.vmp.basedata.controller;

import com.copote.vmp.basedata.config.properties.BasedataProperties;
import com.copote.vmp.basedata.model.Result;
import com.copote.vmp.basedata.model.entity.DriverInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@Slf4j
@RestController
@RequestMapping("/driver")
@Api(tags = "驾驶员信息")
public class DriverInfoController {

    @Autowired
    private BasedataProperties basedataProperties;

    @Value("${standard-datetime-format}")
    private String standardDatetimeFormat;

    @GetMapping("/getDriverInfo")
    @ApiOperation(value = "获取驾驶员详情", notes = "根据id查询驾驶员的详细信息")
    Result<DriverInfo> getVehicleInfo(@RequestParam String id) {
        log.info("Standard Datetime Format: {}", standardDatetimeFormat);
        DriverInfo driverInfo = new DriverInfo();
        driverInfo.setId(id)
                .setName("汤姆")
                .setLicenseNumber(basedataProperties.getSecretKey())
                .setCreateTime(new Date());
        return Result.ok(driverInfo);
    }
}
